package com.autonavi.notify.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.autonavi.notify.entity.Notify;
import com.autonavi.notify.service.NotifyService;


@Controller
public class NotifyCtrl {
	
	@Autowired
	NotifyService notifyService;
	
	@RequestMapping(value = "/notify/add")
	@ResponseBody
	public String addNotify(@ModelAttribute Notify notify){
		notify.setTimestamp(new Date());
		notifyService.save(notify);
		return "succ";
	}
	
	@RequestMapping(value = "/notify/page/{page}")
	@ResponseBody
	public Page<Notify> getNotify(String requestCode,@PathVariable int page){
		return notifyService.findAll(requestCode, page);
	}

}
